import request from '@/utils/request'

export function getDatabases() {
  return request({
    url: '/maku-generator/gen/datasource/list',
    method: 'get'
  })
}

export function useDatabaseTableList(data) {
  return request({
    url: '/maku-generator/gen/datasource/table/list/' + data,
    method: 'get'
  })
}
export function useTableImportSubmitApi(datasourceId, tableNameList) {
  return request({
    url: '/maku-generator/gen/table/import/' + datasourceId,
    method: 'post',
    data: tableNameList
  })
}

// 生成代码（zip压缩包）
export const useDownloadApi = (tableIds) => {
  location.href = process.env.VUE_APP_BASE_API + '/maku-generator/gen/generator/download?tableIds=' + tableIds.join(',')
}

// 生成代码（自定义目录）
export const useGeneratorApi = (tableIds) => {
  return request.post('/maku-generator/gen/generator/code', tableIds)
}
